ace.define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor"],function(e,t,n){var i=e("../snippets").snippetManager,o=e("../autocomplete").Autocomplete,r=e("../config"),s=e("../autocomplete/util"),a=e("../autocomplete/text_completer"),c={getCompletions:function(e,t,n,i,o){var r=e.session.getState(n.row),s=t.$mode.getCompletions(r,t,n,i);o(null,s)}},h={getCompletions:function(e,t,n,o,r){var s=i.snippetMap,a=[];i.getActiveScopes(e).forEach(function(e){for(var t=s[e]||[],n=t.length;n--;){var i=t[n],o=i.name||i.tabTrigger;o&&a.push({caption:o,snippet:i.content,meta:i.tabTrigger&&!i.name?i.tabTrigger+"⇥ ":"snippet"})}},this),r(null,a)}},l=[h,a,c];t.addCompleter=function(e){l.push(e)},t.textCompleter=a,t.keyWordCompleter=c,t.snippetCompleter=h;var p={name:"expandSnippet",exec:function(e){var t=i.expandWithTab(e);t||e.execCommand("indent")},bindKey:"Tab"},u=function(e,t){d(t.session.$mode)},d=function(e){var t=e.$id;i.files||(i.files={}),g(t),e.modes&&e.modes.forEach(d)},g=function(e){if(e&&!i.files[e]){var t=e.replace("mode","snippets");i.files[e]={},r.loadModule(t,function(t){t&&(i.files[e]=t,!t.snippets&&t.snippetText&&(t.snippets=i.parseSnippetFile(t.snippetText)),i.register(t.snippets||[],t.scope),t.includeScopes&&(i.snippetMap[t.scope].includeScopes=t.includeScopes,t.includeScopes.forEach(function(e){g("ace/mode/"+e)})))})}},f=function(e){var t=e.editor,n=e.args||"",i=t.getCursorPosition(),r=t.session.getLine(i.row),a=t.completer&&t.completer.activated,c=s.retrievePrecedingIdentifier(r,i.column);l.forEach(function(e){e.identifierRegexps&&e.identifierRegexps.forEach(function(e){c||(c=s.retrievePrecedingIdentifier(r,i.column,e))})}),"backspace"!==e.command.name||c?"insertstring"===e.command.name&&(c&&!a?(t.completer||(t.completer=new o,t.completer.autoSelect=!1,t.completer.autoInsert=!1),t.completer.showPopup(t)):!c&&a&&t.completer.detach()):a&&t.completer.detach()},m=e("../editor").Editor;e("../config").defineOptions(m.prototype,"editor",{enableBasicAutocompletion:{set:function(e){e?(this.completers=Array.isArray(e)?e:l,this.commands.addCommand(o.startCommand)):this.commands.removeCommand(o.startCommand)},value:!1},enableLiveAutocompletion:{set:function(e){e?(this.completers=Array.isArray(e)?e:l,this.commands.on("afterExec",f)):this.commands.removeListener("afterExec",f)},value:!1},enableSnippets:{set:function(e){e?(this.commands.addCommand(p),this.on("changeMode",u),u(null,this)):(this.commands.removeCommand(p),this.off("changeMode",u))},value:!1}})}),ace.define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"],function(e,t,n){var i=e("./lib/oop"),o=e("./lib/event_emitter").EventEmitter,r=e("./lib/lang"),s=e("./range").Range,a=e("./anchor").Anchor,c=e("./keyboard/hash_handler").HashHandler,h=e("./tokenizer").Tokenizer,l=s.comparePoints,p=function(){this.snippetMap={},this.snippetNameMap={}};(function(){i.implement(this,o),this.getTokenizer=function(){function e(e,t,n){return e=e.substr(1),/^\d+$/.test(e)&&!n.inFormatString?[{tabstopId:parseInt(e,10)}]:[{text:e}]}function t(e){return"(?:[^\\\\"+e+"]|\\\\.)"}return p.$tokenizer=new h({start:[{regex:/:/,onMatch:function(e,t,n){return n.length&&n[0].expectIf?(n[0].expectIf=!1,n[0].elseBranch=n[0],[n[0]]):":"}},{regex:/\\./,onMatch:function(e,t,n){var i=e[1];return"}"==i&&n.length?e=i:-1!="`$\\".indexOf(i)?e=i:n.inFormatString&&("n"==i?e="\n":"t"==i?e="\n":-1!="ulULE".indexOf(i)&&(e={changeCase:i,local:i>"a"})),[e]}},{regex:/}/,onMatch:function(e,t,n){return[n.length?n.shift():e]}},{regex:/\$(?:\d+|\w+)/,onMatch:e},{regex:/\$\{[\dA-Z_a-z]+/,onMatch:function(t,n,i){var o=e(t.substr(1),n,i);return i.unshift(o[0]),o},next:"snippetVar"},{regex:/\n/,token:"newline",merge:!1}],snippetVar:[{regex:"\\|"+t("\\|")+"*\\|",onMatch:function(e,t,n){n[0].choices=e.slice(1,-1).split(",")},next:"start"},{regex:"/("+t("/")+"+)/(?:("+t("/")+"*)/)(\\w*):?",onMatch:function(e,t,n){var i=n[0];return i.fmtString=e,e=this.splitRegex.exec(e),i.guard=e[1],i.fmt=e[2],i.flag=e[3],""},next:"start"},{regex:"`"+t("`")+"*`",onMatch:function(e,t,n){return n[0].code=e.splice(1,-1),""},next:"start"},{regex:"\\?",onMatch:function(e,t,n){n[0]&&(n[0].expectIf=!0)},next:"start"},{regex:"([^:}\\\\]|\\\\.)*:?",token:"",next:"start"}],formatString:[{regex:"/("+t("/")+"+)/",token:"regex"},{regex:"",onMatch:function(e,t,n){n.inFormatString=!0},next:"start"}]}),p.prototype.getTokenizer=function(){return p.$tokenizer},p.$tokenizer},this.tokenizeTmSnippet=function(e,t){return this.getTokenizer().getLineTokens(e,t).tokens.map(function(e){return e.value||e})},this.$getDefaultValue=function(e,t){if(/^[A-Z]\d+$/.test(t)){var n=t.substr(1);return(this.variables[t[0]+"__"]||{})[n]}if(/^\d+$/.test(t))return(this.variables.__||{})[t];if(t=t.replace(/^TM_/,""),e){var i=e.session;switch(t){case"CURRENT_WORD":var o=i.getWordRange();case"SELECTION":case"SELECTED_TEXT":return i.getTextRange(o);case"CURRENT_LINE":return i.getLine(e.getCursorPosition().row);case"PREV_LINE":return i.getLine(e.getCursorPosition().row-1);case"LINE_INDEX":return e.getCursorPosition().column;case"LINE_NUMBER":return e.getCursorPosition().row+1;case"SOFT_TABS":return i.getUseSoftTabs()?"YES":"NO";case"TAB_SIZE":return i.getTabSize();case"FILENAME":case"FILEPATH":return"";case"FULLNAME":return"Ace"}}},this.variables={},this.getVariableValue=function(e,t){return this.variables.hasOwnProperty(t)?this.variables[t](e,t)||"":this.$getDefaultValue(e,t)||""},this.tmStrFormat=function(e,t,n){var i=t.flag||"",o=t.guard;o=new RegExp(o,i.replace(/[^gi]/,""));var r=this.tokenizeTmSnippet(t.fmt,"formatString"),s=this,a=e.replace(o,function(){s.variables.__=arguments;for(var e=s.resolveVariables(r,n),t="E",i=0;i<e.length;i++){var o=e[i];if("object"==typeof o)if(e[i]="",o.changeCase&&o.local){var a=e[i+1];a&&"string"==typeof a&&(e[i]="u"==o.changeCase?a[0].toUpperCase():a[0].toLowerCase(),e[i+1]=a.substr(1))}else o.changeCase&&(t=o.changeCase);else"U"==t?e[i]=o.toUpperCase():"L"==t&&(e[i]=o.toLowerCase())}return e.join("")});return this.variables.__=null,a},this.resolveVariables=function(e,t){function n(t){var n=e.indexOf(t,o+1);-1!=n&&(o=n)}for(var i=[],o=0;o<e.length;o++){var r=e[o];if("string"==typeof r)i.push(r);else{if("object"!=typeof r)continue;if(r.skip)n(r);else{if(r.processed<o)continue;if(r.text){var s=this.getVariableValue(t,r.text);s&&r.fmtString&&(s=this.tmStrFormat(s,r)),r.processed=o,null==r.expectIf?s&&(i.push(s),n(r)):s?r.skip=r.elseBranch:n(r)}else null!=r.tabstopId?i.push(r):null!=r.changeCase&&i.push(r)}}}return i},this.insertSnippetForSelection=function(e,t){function n(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];if("object"==typeof i){if(h[i.tabstopId])continue;var o=e.lastIndexOf(i,n-1);i=t[o]||{tabstopId:i.tabstopId}}t[n]=i}return t}var i=e.getCursorPosition(),o=e.session.getLine(i.row),r=e.session.getTabString(),s=o.match(/^\s*/)[0];i.column<s.length&&(s=s.slice(0,i.column));var a=this.tokenizeTmSnippet(t);a=this.resolveVariables(a,e),a=a.map(function(e){return"\n"==e?e+s:"string"==typeof e?e.replace(/\t/g,r):e});var c=[];a.forEach(function(e,t){if("object"==typeof e){var n=e.tabstopId,i=c[n];if(i||(i=c[n]=[],i.index=n,i.value=""),-1===i.indexOf(e)){i.push(e);var o=a.indexOf(e,t+1);if(-1!==o){var r=a.slice(t+1,o),s=r.some(function(e){return"object"==typeof e});s&&!i.value?i.value=r:r.length&&(!i.value||"string"!=typeof i.value)&&(i.value=r.join(""))}}}}),c.forEach(function(e){e.length=0});for(var h={},l=0;l<a.length;l++){var p=a[l];if("object"==typeof p){var d=p.tabstopId,g=a.indexOf(p,l+1);if(h[d])h[d]===p&&(h[d]=null);else{var f=c[d],m="string"==typeof f.value?[f.value]:n(f.value);m.unshift(l+1,Math.max(0,g-l)),m.push(p),h[d]=p,a.splice.apply(a,m),-1===f.indexOf(p)&&f.push(p)}}}var v=0,b=0,x="";a.forEach(function(e){"string"==typeof e?("\n"===e[0]?(b=e.length-1,v++):b+=e.length,x+=e):e.start?e.end={row:v,column:b}:e.start={row:v,column:b}});var w=e.getSelectionRange(),S=e.session.replace(w,x),C=new u(e),T=e.inVirtualSelectionMode&&e.selection.index;C.addTabstops(c,w.start,S,T)},this.insertSnippet=function(e,t){var n=this;return e.inVirtualSelectionMode?n.insertSnippetForSelection(e,t):(e.forEachSelection(function(){n.insertSnippetForSelection(e,t)},null,{keepOrder:!0}),void(e.tabstopManager&&e.tabstopManager.tabNext()))},this.$getScope=function(e){var t=e.session.$mode.$id||"";if(t=t.split("/").pop(),"html"===t||"php"===t){"php"===t&&!e.session.$mode.inlinePhp&&(t="html");var n=e.getCursorPosition(),i=e.session.getState(n.row);"object"==typeof i&&(i=i[0]),i.substring&&("js-"==i.substring(0,3)?t="javascript":"css-"==i.substring(0,4)?t="css":"php-"==i.substring(0,4)&&(t="php"))}return t},this.getActiveScopes=function(e){var t=this.$getScope(e),n=[t],i=this.snippetMap;return i[t]&&i[t].includeScopes&&n.push.apply(n,i[t].includeScopes),n.push("_"),n},this.expandWithTab=function(e,t){var n=this,i=e.forEachSelection(function(){return n.expandSnippetForSelection(e,t)},null,{keepOrder:!0});return i&&e.tabstopManager&&e.tabstopManager.tabNext(),i},this.expandSnippetForSelection=function(e,t){var n=e.getCursorPosition(),i=e.session.getLine(n.row),o=i.substring(0,n.column),r=i.substr(n.column),s=this.snippetMap,a;return this.getActiveScopes(e).some(function(e){var t=s[e];return t&&(a=this.findMatchingSnippet(t,o,r)),!!a},this),a?t&&t.dryRun?!0:(e.session.doc.removeInLine(n.row,n.column-a.replaceBefore.length,n.column+a.replaceAfter.length),this.variables.M__=a.matchBefore,this.variables.T__=a.matchAfter,this.insertSnippetForSelection(e,a.content),this.variables.M__=this.variables.T__=null,!0):!1},this.findMatchingSnippet=function(e,t,n){for(var i=e.length;i--;){var o=e[i];if(!(o.startRe&&!o.startRe.test(t)||o.endRe&&!o.endRe.test(n)||!o.startRe&&!o.endRe))return o.matchBefore=o.startRe?o.startRe.exec(t):[""],o.matchAfter=o.endRe?o.endRe.exec(n):[""],o.replaceBefore=o.triggerRe?o.triggerRe.exec(t)[0]:"",o.replaceAfter=o.endTriggerRe?o.endTriggerRe.exec(n)[0]:"",o}},this.snippetMap={},this.snippetNameMap={},this.register=function(e,t){function n(e){return e&&!/^\^?\(.*\)\$?$|^\\b$/.test(e)&&(e="(?:"+e+")"),e||""}function i(e,t,i){return e=n(e),t=n(t),i?(e=t+e,e&&"$"!=e[e.length-1]&&(e+="$")):(e+=t,e&&"^"!=e[0]&&(e="^"+e)),new RegExp(e)}function o(e){e.scope||(e.scope=t||"_"),t=e.scope,s[t]||(s[t]=[],a[t]={});var n=a[t];if(e.name){var o=n[e.name];o&&c.unregister(o),n[e.name]=e}s[t].push(e),e.tabTrigger&&!e.trigger&&(!e.guard&&/^\w/.test(e.tabTrigger)&&(e.guard="\\b"),e.trigger=r.escapeRegExp(e.tabTrigger)),e.startRe=i(e.trigger,e.guard,!0),e.triggerRe=new RegExp(e.trigger,"",!0),e.endRe=i(e.endTrigger,e.endGuard,!0),e.endTriggerRe=new RegExp(e.endTrigger,"",!0)}var s=this.snippetMap,a=this.snippetNameMap,c=this;e.content?o(e):Array.isArray(e)&&e.forEach(o),this._signal("registerSnippets",{scope:t})},this.unregister=function(e,t){function n(e){var n=o[e.scope||t];if(n&&n[e.name]){delete n[e.name];var r=i[e.scope||t],s=r&&r.indexOf(e);s>=0&&r.splice(s,1)}}var i=this.snippetMap,o=this.snippetNameMap;e.content?n(e):Array.isArray(e)&&e.forEach(n)},this.parseSnippetFile=function(e){e=e.replace(/\r/g,"");for(var t=[],n={},i=/^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm,o;o=i.exec(e);){if(o[1])try{n=JSON.parse(o[1]),t.push(n)}catch(r){}if(o[4])n.content=o[4].replace(/^\t/gm,""),t.push(n),n={};else{var s=o[2],a=o[3];if("regex"==s){var c=/\/((?:[^\/\\]|\\.)*)|$/g;n.guard=c.exec(a)[1],n.trigger=c.exec(a)[1],n.endTrigger=c.exec(a)[1],n.endGuard=c.exec(a)[1]}else"snippet"==s?(n.tabTrigger=a.match(/^\S*/)[0],n.name||(n.name=a)):n[s]=a}}return t},this.getSnippetByName=function(e,t){var n=this.snippetNameMap,i;return this.getActiveScopes(t).some(function(t){var o=n[t];return o&&(i=o[e]),!!i},this),i}}).call(p.prototype);var u=function(e){return e.tabstopManager?e.tabstopManager:(e.tabstopManager=this,this.$onChange=this.onChange.bind(this),this.$onChangeSelection=r.delayedCall(this.onChangeSelection.bind(this)).schedule,this.$onChangeSession=this.onChangeSession.bind(this),this.$onAfterExec=this.onAfterExec.bind(this),this.attach(e),void 0)};(function(){this.attach=function(e){this.index=0,this.ranges=[],this.tabstops=[],this.$openTabstops=null,this.selectedTabstop=null,this.editor=e,this.editor.on("change",this.$onChange),this.editor.on("changeSelection",this.$onChangeSelection),this.editor.on("changeSession",this.$onChangeSession),this.editor.commands.on("afterExec",this.$onAfterExec),this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler)},this.detach=function(){this.tabstops.forEach(this.removeTabstopMarkers,this),this.ranges=null,this.tabstops=null,this.selectedTabstop=null,this.editor.removeListener("change",this.$onChange),this.editor.removeListener("changeSelection",this.$onChangeSelection),this.editor.removeListener("changeSession",this.$onChangeSession),this.editor.commands.removeListener("afterExec",this.$onAfterExec),this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler),this.editor.tabstopManager=null,this.editor=null},this.onChange=function(e){var t=e.data.range,n="r"==e.data.action[0],i=t.start,o=t.end,r=i.row,s=o.row,a=s-r,c=o.column-i.column;if(n&&(a=-a,c=-c),!this.$inChange&&n){var h=this.selectedTabstop,p=h&&!h.some(function(e){return l(e.start,i)<=0&&l(e.end,o)>=0});if(p)return this.detach()}for(var u=this.ranges,d=0;d<u.length;d++){var g=u[d];g.end.row<i.row||(n&&l(i,g.start)<0&&l(o,g.end)>0?(this.removeRange(g),d--):(g.start.row==r&&g.start.column>i.column&&(g.start.column+=c),g.end.row==r&&g.end.column>=i.column&&(g.end.column+=c),g.start.row>=r&&(g.start.row+=a),g.end.row>=r&&(g.end.row+=a),l(g.start,g.end)>0&&this.removeRange(g)))}u.length||this.detach()},this.updateLinkedFields=function(){var e=this.selectedTabstop;if(e&&e.hasLinkedRanges){this.$inChange=!0;for(var n=this.editor.session,i=n.getTextRange(e.firstNonLinked),o=e.length;o--;){var r=e[o];if(r.linked){var s=t.snippetManager.tmStrFormat(i,r.original);n.replace(r,s)}}this.$inChange=!1}},this.onAfterExec=function(e){e.command&&!e.command.readOnly&&this.updateLinkedFields()},this.onChangeSelection=function(){if(this.editor){for(var e=this.editor.selection.lead,t=this.editor.selection.anchor,n=this.editor.selection.isEmpty(),i=this.ranges.length;i--;)if(!this.ranges[i].linked){var o=this.ranges[i].contains(e.row,e.column),r=n||this.ranges[i].contains(t.row,t.column);if(o&&r)return}this.detach()}},this.onChangeSession=function(){this.detach()},this.tabNext=function(e){var t=this.tabstops.length,n=this.index+(e||1);n=Math.min(Math.max(n,1),t),n==t&&(n=0),this.selectTabstop(n),0===n&&this.detach()},this.selectTabstop=function(e){this.$openTabstops=null;var t=this.tabstops[this.index];if(t&&this.addTabstopMarkers(t),this.index=e,t=this.tabstops[this.index],t&&t.length){if(this.selectedTabstop=t,this.editor.inVirtualSelectionMode)this.editor.selection.setRange(t.firstNonLinked);else{var n=this.editor.multiSelect;n.toSingleRange(t.firstNonLinked.clone());for(var i=t.length;i--;)t.hasLinkedRanges&&t[i].linked||n.addRange(t[i].clone(),!0);n.ranges[0]&&n.addRange(n.ranges[0].clone())}this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler)}},this.addTabstops=function(e,t,n){if(this.$openTabstops||(this.$openTabstops=[]),!e[0]){var i=s.fromPoints(n,n);f(i.start,t),f(i.end,t),e[0]=[i],e[0].index=0}var o=this.index,r=[o+1,0],a=this.ranges;e.forEach(function(e,n){for(var i=this.$openTabstops[n]||e,o=e.length;o--;){var c=e[o],h=s.fromPoints(c.start,c.end||c.start);g(h.start,t),g(h.end,t),h.original=c,h.tabstop=i,a.push(h),i!=e?i.unshift(h):i[o]=h,c.fmtString?(h.linked=!0,i.hasLinkedRanges=!0):i.firstNonLinked||(i.firstNonLinked=h)}i.firstNonLinked||(i.hasLinkedRanges=!1),i===e&&(r.push(i),this.$openTabstops[n]=i),this.addTabstopMarkers(i)},this),r.length>2&&(this.tabstops.length&&r.push(r.splice(2,1)[0]),this.tabstops.splice.apply(this.tabstops,r))},this.addTabstopMarkers=function(e){var t=this.editor.session;e.forEach(function(e){e.markerId||(e.markerId=t.addMarker(e,"ace_snippet-marker","text"))})},this.removeTabstopMarkers=function(e){var t=this.editor.session;e.forEach(function(e){t.removeMarker(e.markerId),e.markerId=null})},this.removeRange=function(e){var t=e.tabstop.indexOf(e);e.tabstop.splice(t,1),t=this.ranges.indexOf(e),this.ranges.splice(t,1),this.editor.session.removeMarker(e.markerId),e.tabstop.length||(t=this.tabstops.indexOf(e.tabstop),-1!=t&&this.tabstops.splice(t,1),this.tabstops.length||this.detach())},this.keyboardHandler=new c,this.keyboardHandler.bindKeys({Tab:function(e){t.snippetManager&&t.snippetManager.expandWithTab(e)||e.tabstopManager.tabNext(1)},"Shift-Tab":function(e){e.tabstopManager.tabNext(-1)},Esc:function(e){e.tabstopManager.detach()},Return:function(e){return!1}})}).call(u.prototype);var d={};d.onChange=a.prototype.onChange,d.setPosition=function(e,t){this.pos.row=e,this.pos.column=t},d.update=function(e,t,n){this.$insertRight=n,this.pos=e,this.onChange(t)};var g=function(e,t){0==e.row&&(e.column+=t.column),e.row+=t.row},f=function(e,t){e.row==t.row&&(e.column-=t.column),e.row-=t.row};e("./lib/dom").importCssString(".ace_snippet-marker {    -moz-box-sizing: border-box;    box-sizing: border-box;    background: rgba(194, 193, 208, 0.09);    border: 1px dotted rgba(211, 208, 235, 0.62);    position: absolute;}"),t.snippetManager=new p;var m=e("./editor").Editor;(function(){this.insertSnippet=function(e,n){return t.snippetManager.insertSnippet(this,e,n)},this.expandSnippet=function(e){return t.snippetManager.expandWithTab(this,e)}}).call(m.prototype)}),ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/event","ace/lib/lang","ace/snippets"],function(e,t,n){var i=e("./keyboard/hash_handler").HashHandler,o=e("./autocomplete/popup").AcePopup,r=e("./autocomplete/util"),s=e("./lib/event"),a=e("./lib/lang"),c=e("./snippets").snippetManager,h=function(){this.autoInsert=!0,this.autoSelect=!0,this.keyboardHandler=new i,this.keyboardHandler.bindKeys(this.commands),this.blurListener=this.blurListener.bind(this),this.changeListener=this.changeListener.bind(this),this.mousedownListener=this.mousedownListener.bind(this),this.mousewheelListener=this.mousewheelListener.bind(this),this.changeTimer=a.delayedCall(function(){this.updateCompletions(!0)}.bind(this))};(function(){this.gatherCompletionsId=0,this.$init=function(){this.popup=new o(document.body||document.documentElement),this.popup.on("click",function(e){this.insertMatch(),e.stop()}.bind(this)),this.popup.focus=this.editor.focus.bind(this.editor)},this.openPopup=function(e,t,n){this.popup||this.$init(),this.popup.setData(this.completions.filtered);var i=e.renderer;if(this.popup.setRow(this.autoSelect?0:-1),!n){this.popup.setTheme(e.getTheme()),this.popup.setFontSize(e.getFontSize());var o=i.layerConfig.lineHeight,r=i.$cursorLayer.getPixelPosition(this.base,!0);r.left-=this.popup.getTextLeftOffset();var s=e.container.getBoundingClientRect();r.top+=s.top-i.layerConfig.offset,r.left+=s.left-e.renderer.scrollLeft,r.left+=i.$gutterLayer.gutterWidth,this.popup.show(r,o)}},this.detach=function(){this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler),this.editor.off("changeSelection",this.changeListener),this.editor.off("blur",this.blurListener),this.editor.off("mousedown",this.mousedownListener),this.editor.off("mousewheel",this.mousewheelListener),this.changeTimer.cancel(),this.popup&&this.popup.isOpen&&(this.gatherCompletionsId=this.gatherCompletionsId+1),this.popup&&this.popup.hide(),this.activated=!1,this.completions=this.base=null},this.changeListener=function(e){var t=this.editor.selection.lead;(t.row!=this.base.row||t.column<this.base.column)&&this.detach(),this.activated?this.changeTimer.schedule():this.detach()},this.blurListener=function(){var e=document.activeElement;e!=this.editor.textInput.getElement()&&e.parentNode!=this.popup.container&&this.detach()},this.mousedownListener=function(e){this.detach()},this.mousewheelListener=function(e){this.detach()},this.goTo=function(e){var t=this.popup.getRow(),n=this.popup.session.getLength()-1;switch(e){case"up":t=0>=t?n:t-1;break;case"down":t=t>=n?-1:t+1;break;case"start":t=0;break;case"end":t=n}this.popup.setRow(t)},this.insertMatch=function(e){if(e||(e=this.popup.getData(this.popup.getRow())),!e)return!1;if(e.completer&&e.completer.insertMatch)e.completer.insertMatch(this.editor);else{if(this.completions.filterText)for(var t=this.editor.selection.getAllRanges(),n=0,i;i=t[n];n++)i.start.column-=this.completions.filterText.length,this.editor.session.remove(i);e.snippet?c.insertSnippet(this.editor,e.snippet):this.editor.execCommand("insertstring",e.value||e)}this.detach()},this.commands={Up:function(e){e.completer.goTo("up")},Down:function(e){e.completer.goTo("down")},"Ctrl-Up|Ctrl-Home":function(e){e.completer.goTo("start")},"Ctrl-Down|Ctrl-End":function(e){e.completer.goTo("end")},Esc:function(e){e.completer.detach()},Space:function(e){e.completer.detach(),e.insert(" ")},Return:function(e){return e.completer.insertMatch()},"Shift-Return":function(e){e.completer.insertMatch(!0)},Tab:function(e){var t=e.completer.insertMatch();return t||e.tabstopManager?t:void e.completer.goTo("down")},PageUp:function(e){e.completer.popup.gotoPageUp()},PageDown:function(e){e.completer.popup.gotoPageDown()}},this.gatherCompletions=function(e,t){var n=e.getSession(),i=e.getCursorPosition(),o=n.getLine(i.row),s=r.retrievePrecedingIdentifier(o,i.column);this.base=e.getCursorPosition(),this.base.column-=s.length;var a=[],c=e.completers.length;return e.completers.forEach(function(o,h){o.getCompletions(e,n,i,s,function(i,o){i||(a=a.concat(o));var s=e.getCursorPosition(),h=n.getLine(s.row);t(null,{prefix:r.retrievePrecedingIdentifier(h,s.column,o[0]&&o[0].identifierRegex),matches:a,finished:0===--c})})}),!0},this.showPopup=function(e){this.editor&&this.detach(),this.activated=!0,this.editor=e,e.completer!=this&&(e.completer&&e.completer.detach(),e.completer=this),e.keyBinding.addKeyboardHandler(this.keyboardHandler),e.on("changeSelection",this.changeListener),e.on("blur",this.blurListener),e.on("mousedown",this.mousedownListener),e.on("mousewheel",this.mousewheelListener),this.updateCompletions()},this.updateCompletions=function(e){if(e&&this.base&&this.completions){var t=this.editor.getCursorPosition(),n=this.editor.session.getTextRange({start:this.base,end:t});if(n==this.completions.filterText)return;return this.completions.setFilter(n),this.completions.filtered.length&&(1!=this.completions.filtered.length||this.completions.filtered[0].value!=n||this.completions.filtered[0].snippet)?void this.openPopup(this.editor,n,e):this.detach()}var i=this.gatherCompletionsId;this.gatherCompletions(this.editor,function(t,n){var o=function(){return n.finished?this.detach():void 0}.bind(this),r=n.prefix,s=n&&n.matches;if(!s||!s.length)return o();if(0===r.indexOf(n.prefix)&&i==this.gatherCompletionsId){this.completions=new l(s),this.completions.setFilter(r);var a=this.completions.filtered;return a.length&&(1!=a.length||a[0].value!=r||a[0].snippet)?this.autoInsert&&1==a.length?this.insertMatch(a[0]):void this.openPopup(this.editor,r,e):o()}}.bind(this))},this.cancelContextMenu=function(){var e=function(t){this.editor.off("nativecontextmenu",e),t&&t.domEvent&&s.stopEvent(t.domEvent)}.bind(this);setTimeout(e,10),this.editor.on("nativecontextmenu",e)}}).call(h.prototype),h.startCommand={name:"startAutocomplete",exec:function(e){e.completer||(e.completer=new h),e.completer.autoInsert=e.completer.autoSelect=!0,e.completer.showPopup(e),e.completer.cancelContextMenu()},bindKey:"Ctrl-Space|Ctrl-Shift-Space|Alt-Space"};var l=function(e,t,n){this.all=e,this.filtered=e,this.filterText=t||""};(function(){this.setFilter=function(e){if(e.length>this.filterText&&0===e.lastIndexOf(this.filterText,0))var t=this.filtered;else var t=this.all;this.filterText=e,t=this.filterCompletions(t,this.filterText),t=t.sort(function(e,t){return t.exactMatch-e.exactMatch||t.score-e.score});var n=null;t=t.filter(function(e){var t=e.value||e.caption||e.snippet;return t===n?!1:(n=t,!0)}),this.filtered=t},this.filterCompletions=function(e,t){var n=[],i=t.toUpperCase(),o=t.toLowerCase();e:for(var r=0,s;s=e[r];r++){var a=s.value||s.caption||s.snippet;if(a){for(var c=-1,h=0,l=0,p,u,d=0;d<t.length;d++){var g=a.indexOf(o[d],c+1),f=a.indexOf(i[d],c+1);if(p=g>=0&&(0>f||f>g)?g:f,0>p)continue e;u=p-c-1,u>0&&(-1===c&&(l+=10),l+=u),h|=1<<p,c=p}s.matchMask=h,s.exactMatch=l?0:1,s.score=(s.score||0)-l,n.push(s)}}return n}}).call(l.prototype),t.Autocomplete=h,t.FilteredList=l}),ace.define("ace/autocomplete/popup",["require","exports","module","ace/edit_session","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"],function(e,t,n){var i=e("../edit_session").EditSession,o=e("../virtual_renderer").VirtualRenderer,r=e("../editor").Editor,s=e("../range").Range,a=e("../lib/event"),c=e("../lib/lang"),h=e("../lib/dom"),l=function(e){var t=new o(e);t.$maxLines=4;var n=new r(t);return n.setHighlightActiveLine(!1),n.setShowPrintMargin(!1),n.renderer.setShowGutter(!1),n.renderer.setHighlightGutterLine(!1),n.$mouseHandler.$focusWaitTimout=0,n},p=function(e){var t=h.createElement("div"),n=new l(t);e&&e.appendChild(t),t.style.display="none",n.renderer.content.style.cursor="default",n.renderer.setStyle("ace_autocomplete"),n.setOption("displayIndentGuides",!1);var i=function(){};n.focus=i,n.$isFocused=!0,n.renderer.$cursorLayer.restartTimer=i,n.renderer.$cursorLayer.element.style.opacity=0,n.renderer.$maxLines=8,n.renderer.$keepTextAreaAtCursor=!1,n.setHighlightActiveLine(!1),n.session.highlight(""),n.session.$searchHighlight.clazz="ace_highlight-marker",n.on("mousedown",function(e){var t=e.getDocumentPosition();n.selection.moveToPosition(t),p.start.row=p.end.row=t.row,e.stop()});var o,r=new s(-1,0,-1,1/0),p=new s(-1,0,-1,1/0);p.id=n.session.addMarker(p,"ace_active-line","fullLine"),n.setSelectOnHover=function(e){e?r.id&&(n.session.removeMarker(r.id),r.id=null):r.id=n.session.addMarker(r,"ace_line-hover","fullLine")},n.setSelectOnHover(!1),n.on("mousemove",function(e){if(!o)return void(o=e);if(o.x!=e.x||o.y!=e.y){o=e,o.scrollTop=n.renderer.scrollTop;var t=o.getDocumentPosition().row;r.start.row!=t&&(r.id||n.setRow(t),d(t))}}),n.renderer.on("beforeRender",function(){if(o&&-1!=r.start.row){o.$pos=null;var e=o.getDocumentPosition().row;r.id||n.setRow(e),d(e,!0)}}),n.renderer.on("afterRender",function(){var e=n.getRow(),t=n.renderer.$textLayer,i=t.element.childNodes[e-t.config.firstRow];i!=t.selectedNode&&(t.selectedNode&&h.removeCssClass(t.selectedNode,"ace_selected"),t.selectedNode=i,i&&h.addCssClass(i,"ace_selected"))});var u=function(){d(-1)},d=function(e,t){e!==r.start.row&&(r.start.row=r.end.row=e,t||n.session._emit("changeBackMarker"),n._emit("changeHoverMarker"))};n.getHoveredRow=function(){return r.start.row},a.addListener(n.container,"mouseout",u),n.on("hide",u),n.on("changeSelection",u),n.session.doc.getLength=function(){return n.data.length},n.session.doc.getLine=function(e){var t=n.data[e];return"string"==typeof t?t:t&&t.value||""};var g=n.session.bgTokenizer;return g.$tokenizeRow=function(e){var t=n.data[e],i=[];if(!t)return i;"string"==typeof t&&(t={value:t}),t.caption||(t.caption=t.value);for(var o=-1,r,s,e=0;e<t.caption.length;e++)s=t.caption[e],r=t.matchMask&1<<e?1:0,o!==r?(i.push({type:t.className||""+(r?"completion-highlight":""),value:s}),o=r):i[i.length-1].value+=s;if(t.meta){var a=n.renderer.$size.scrollerWidth/n.renderer.layerConfig.characterWidth;t.meta.length+t.caption.length<a-2&&i.push({type:"rightAlignedText",value:t.meta})}return i},g.$updateOnChange=i,g.start=i,n.session.$computeWidth=function(){return this.screenWidth=0},n.isOpen=!1,n.isTopdown=!1,n.data=[],n.setData=function(e){n.data=e||[],n.setValue(c.stringRepeat("\n",e.length),-1),n.setRow(0)},n.getData=function(e){return n.data[e]},n.getRow=function(){return p.start.row},n.setRow=function(e){e=Math.max(-1,Math.min(this.data.length,e)),p.start.row!=e&&(n.selection.clearSelection(),p.start.row=p.end.row=e||0,n.session._emit("changeBackMarker"),n.moveCursorTo(e||0,0),n.isOpen&&n._signal("select"))},n.on("changeSelection",function(){n.isOpen&&n.setRow(n.selection.lead.row)}),n.hide=function(){this.container.style.display="none",this._signal("hide"),n.isOpen=!1},n.show=function(e,t,i){var r=this.container,s=window.innerHeight,a=window.innerWidth,c=this.renderer,h=c.$maxLines*t*1.4,l=e.top+this.$borderSize;l+h>s-t&&!i?(r.style.top="",r.style.bottom=s-l+"px",n.isTopdown=!1):(l+=t,r.style.top=l+"px",r.style.bottom="",n.isTopdown=!0),r.style.display="",this.renderer.$textLayer.checkForSizeChanges();var p=e.left;p+r.offsetWidth>a&&(p=a-r.offsetWidth),r.style.left=p+"px",this._signal("show"),o=null,n.isOpen=!0},n.getTextLeftOffset=function(){return this.$borderSize+this.renderer.$padding+this.$imageSize},n.$imageSize=0,n.$borderSize=1,n};h.importCssString(".ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {    background-color: #CAD6FA;    z-index: 1;}.ace_editor.ace_autocomplete .ace_line-hover {    border: 1px solid #abbffe;    margin-top: -1px;    background: rgba(233,233,253,0.4);}.ace_editor.ace_autocomplete .ace_line-hover {    position: absolute;    z-index: 2;}.ace_editor.ace_autocomplete .ace_scroller {   background: none;   border: none;   box-shadow: none;}.ace_rightAlignedText {    color: gray;    display: inline-block;    position: absolute;    right: 4px;    text-align: right;    z-index: -1;}.ace_editor.ace_autocomplete .ace_completion-highlight{    color: #000;    text-shadow: 0 0 0.01em;}.ace_editor.ace_autocomplete {    width: 280px;    z-index: 200000;    background: #fbfbfb;    color: #444;    border: 1px lightgray solid;    position: fixed;    box-shadow: 2px 3px 5px rgba(0,0,0,.2);    line-height: 1.4;}"),t.AcePopup=p}),ace.define("ace/autocomplete/util",["require","exports","module"],function(e,t,n){t.parForEach=function(e,t,n){var i=0,o=e.length;0===o&&n();for(var r=0;o>r;r++)t(e[r],function(e,t){i++,i===o&&n(e,t)})};var i=/[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;t.retrievePrecedingIdentifier=function(e,t,n){n=n||i;for(var o=[],r=t-1;r>=0&&n.test(e[r]);r--)o.push(e[r]);return o.reverse().join("")},t.retrieveFollowingIdentifier=function(e,t,n){n=n||i;for(var o=[],r=t;r<e.length&&n.test(e[r]);r++)o.push(e[r]);return o}}),ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/range"],function(e,t,n){function i(e,t){var n=e.getTextRange(r.fromPoints({row:0,column:0},t));return n.split(s).length-1}function o(e,t){var n=i(e,t),o=e.getValue().split(s),r=Object.create(null),a=o[n];return o.forEach(function(e,t){if(e&&e!==a){var i=Math.abs(n-t),s=o.length-i;r[e]=r[e]?Math.max(s,r[e]):s}}),r}var r=e("../range").Range,s=/[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;t.getCompletions=function(e,t,n,i,r){var s=o(t,n,i),a=Object.keys(s);r(null,a.map(function(e){return{name:e,value:e,score:s[e],meta:"local"}}))}}),function(){ace.require(["ace/ext/language_tools"],function(){})}();